from flask import Flask
from argparse import ArgumentParser
from apiserver_init import app_sequence
import config_repo

app = Flask(__name__)
app = app_sequence.AppSequence(app).start()

if __name__ == "__main__":
    p = ArgumentParser(description=__doc__)
    p.add_argument(
        "--port", "-p", type=int, default=config_repo.apiserver['server']['port']
    )
    p.add_argument("--ip", "-i", type=str, default=config_repo.apiserver['server']['host']
    )
    p.add_argument(
        "--debug", action="store_true", default=config_repo.apiserver['server']['debug']
    )
    args = p.parse_args()

    app.run(
        debug=args.debug,
        host=args.ip,
        port=args.port,
        threaded=True
    )